<?php

	// The controller manages resource access and business logic

	// User was logged in? If not, go to login page
	require_once $app_inc_path.'authentication.php';
	
	if (!isUserLoggedIn()) {
	   
		$show_page = $app_resources[checkAccessAllowed($_REQUEST['r'], $login_page)];
		
	} else {
	
		// Include php script associated with resource. 
		// If resource code is not valid, show error 404, if resource
		// code is not defined, show welcome page.
	    if (isset($_REQUEST['r'])) {
	    	
	    	if (isset($app_resources[$_REQUEST['r']])) {
	    	
	    		$show_page=$app_resources[$_REQUEST['r']];
	    	
	        } else {
	            
	            $show_page=$app_resources["e404"];
	            
	        }
	    	
	    } else {
	
	        $show_page=$app_resources["0002"];
	
	    }
	}
	
    require_once $app_inc_path.$show_page.'.php';

?>